"use client"

import DashboardLayout from '@/components/layout/dashboard-layout'
import { useState, useEffect } from 'react'
import { useRouter } from 'next/navigation'

export default function DashboardPage() {
  const router = useRouter()
  const [loading, setLoading] = useState(true)

  useEffect(() => {
    // 模拟加载数据
    const timer = setTimeout(() => {
      setLoading(false)
      // 保持原来的重定向行为，确保访问 /dashboard 时仍跳转到样品管理
      router.push("/dashboard/samples")
    }, 500)

    return () => clearTimeout(timer)
  }, [router])

  if (loading) {
    return (
      <DashboardLayout>
        <div className="flex items-center justify-center min-h-screen">
          <div className="animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"></div>
          <p className="ml-4 text-blue-600">加载中...</p>
        </div>
      </DashboardLayout>
    )
  }

  // 这个返回值实际上不会被渲染，因为上面已经重定向了
  return (
    <DashboardLayout>
      <div className="p-6">
        <h1 className="text-2xl font-bold">仪表盘</h1>
      </div>
    </DashboardLayout>
  )
}
